package com.heima.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chenshan
 */
@Configuration
public class ESClient {
    @Autowired
    private EsConfig config;

    @Bean
    public RestHighLevelClient getEsClient() {
        return new RestHighLevelClient(RestClient.builder(HttpHost.create(config.getHost() + ":" + config.getPort())));
    }
}
